class ArticlesController < ApplicationController

	caches_page :show
  
  layout "home"
	before_filter :set_bottomlinks
	before_filter :set_toplinks
	before_filter :set_about
	before_filter :set_contact_us
	before_filter :set_our_services
	before_filter :set_menu
	before_filter :set_current_top_category
  
  def show
    #@article = Article.find_by_permalink(params[:id])
		unless @article.nil?
    	@page_title << " - #{@article.title}"
		end
		
		@droite = Article.ez_find(:all, :include => [:category,:tags,:taggings], :order => "published_at") do |article, category, tag, tagging|
      category.permalink == @article.category.permalink 
      article.published == 1
			tag.name == 'droite'
    end	

		if @droite.empty?
			parent_category = @article.category.parent
			unless parent_category.nil?
				@droite = Article.ez_find(:all, :include => [:category,:tags,:taggings], :order => "published_at") do |article, category, tag, tagging|
		      category.permalink == parent_category.permalink
		      article.published == 1
					tag.name == 'droite'
		    end
			end
		end

  end

	def contact
		@sidebar = Article.find(:first, :conditions => ["permalink = ? AND published = 1 ", "contact-droite"])
	end
	
end
